package org.gd.helloconcurrent.futures_and_callables;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public class MySlowRunnable extends MyRunnable {

    private static final AtomicInteger classCount = new AtomicInteger(0);
    private final long countUntil;

    public MySlowRunnable(long countUntil) {
        super(countUntil);
        this.countUntil = countUntil;
    }

    @Override
    public void run() {
        AtomicLong sum = new AtomicLong(0);
        for (long i = 1; i < countUntil; i++) {
            sum.addAndGet(i);
        }
        System.out.printf("[%3d]: sum: %d\n", classCount.incrementAndGet(), sum.get());
    }
}
